
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib prefix="codec" uri="/WEB-INF/tld/codec.tld"%>
<%@ include file="/WEB-INF/common/taglibs.jsp"%>
<script type="text/javascript" src="${ctx}/resources/js/datatable-query.js"></script>
<input type="hidden"  class="filterdata" field="feedbackConfig.id" op="eq" value="${entity.id}" />
<div class="row-fluid">
	<div class="span12">
		<div class="box gradient">
			<div class="title">
				<h4>
					<span>Option Feed Back Manager </span> <span class="box-form right">
					</span>
				</h4>
				<a href="#" class="minimize"></a>
			</div>

			<div class="content scrollable clearfix">
				<table class="ajaxTable display table table-bordered">
					<thead>
						<tr>
							<th><a class="select_all"><span class="icomoon-icon-checkmark-2"></span></a></th>
							<th>Submit Date </th>
<c:forEach items="${entity.additionColumn}" var="column" >

<th>${column.viewName} </th>
</c:forEach>							
						</tr>
					</thead>
				</table>
			</div>
		</div>
	</div>
 	<script type="text/javascript">
 	
 		function getValue(key , datas){
  			var result = "";
			$(datas).each(function(step,value){
				if (value.attrOption.name == key){
						if(value.attrOption.optionType=='FILE'){
							if (value.value){
	 	 						result = value.value;
	 	 						var x= $("<a>").attr("target","_blank").attr("href",value.value).text("Download");
 		  	 						result =	x[0].outerHTML;
  							}

 						}else{
	 						result = value.value;
							
						}
 						return false;
				}	
 			});
			return result;
 			
 	
 		}
		var render = false;
		var sequence = [<c:forEach items="${entity.additionColumn}" var="column"  varStatus="status">
		'${column.name}' <c:if test="${!status.last}">,</c:if>
		</c:forEach>];

		$(document).ready(function() {
			johnny.oTable = $('.ajaxTable').dataTable({
				"aoColumnDefs" : [ {
					'bSortable' : false,
					'aTargets' : [0 
					              <c:forEach items="${entity.additionColumn}" var="column" varStatus="step">
						,${step.index}+2 
					</c:forEach>	
					              ]
				} ],
				"bLengthChange" : true,
				"sAjaxSource" : '${ctx}/admin/option-feed-back/',
				"fnInitComplete" : function(oSettings, json) {
				}
			});
			var name = $("<input>").attr({
				type : "text",
				field : "name",
				op : "cn",
				placeholder : "Name",
				class : "filterdata"
			});
//			johnny.initTableQuery(name);
			
			var del = {
			id : 'optionFeedBackDel',
			text  : 'Del',
			domain : "Option Feed Back",
			operation : "Del",
			url : "${ctx}/admin/option-feed-back/del/" 			};
			johnny.tableBtn(del);
 		});

		var columnHeader = [ '', 'submitDate','feedbackOptionValues' ];
		var QueryData = function(aoData) {
			return johnny.initQueryData(aoData, columnHeader);
		}

		var DataTableForm = function(json, echo) {
			var dataArray = new Array();
			for ( var i = 0; i < json.result.length; i++) {
				var link = "${ctx}/admin/option-feed-back/"+json.result[i].id+"/edit/";
				var subArray = new Array();
				var value = johnny.getForSelect(json.result[i].id);
				subArray.push(value);
				subArray.push(json.result[i].submitDate)
				
				for (var x = 0; x< sequence.length;x++){
										
					subArray.push(getValue(sequence[x],json.result[i].feedbackOptionValues));
				}
				

 				dataArray.push(subArray);
			}
			return {
				sEcho : echo,
				iTotalRecords : json.totalCount,
				iTotalDisplayRecords : json.totalCount,
				aaData : dataArray
			};
		}

	 
	</script>
</div>
